package com.yzf.enterprise.framework.web.domain;

import java.io.Serializable;
import java.util.HashMap;

import com.yzf.enterprise.common.constant.HttpStatus;
import com.yzf.enterprise.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 操作消息提醒
 *
 * @author china
 */
@ApiModel(description = "返回结果")
public class AjaxResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 状态码
     */
    @ApiModelProperty("状态码")
    private int code;

    /**
     * 状态信息
     */
    @ApiModelProperty("状态信息")
    private String msg;

    /**
     * 返回结果
     */
    @ApiModelProperty("数据结果")
    private T result;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public AjaxResult() {
    }

    public AjaxResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public AjaxResult(int code, String msg,T result) {
        this.code = code;
        this.msg = msg;
        this.result = result;
    }


    public static AjaxResult success() {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(HttpStatus.SUCCESS);
        ajaxResult.setMsg("操作成功");
        return ajaxResult;
    }

    public static AjaxResult success(String msg) {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(HttpStatus.SUCCESS);
        ajaxResult.setMsg(msg);
        return ajaxResult;
    }

    public static AjaxResult success(int code, String msg) {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code);
        ajaxResult.setMsg(msg);
        return ajaxResult;
    }

    public static AjaxResult error() {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(HttpStatus.ERROR);
        ajaxResult.setMsg("操作失败");
        return ajaxResult;
    }

    public static AjaxResult error(String msg) {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(HttpStatus.ERROR);
        ajaxResult.setMsg(msg);
        return ajaxResult;
    }

    public static AjaxResult error(int code, String msg) {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code);
        ajaxResult.setMsg(msg);
        return ajaxResult;
    }
}
